class Dog:
    def __init__(self, name, breed, age):
        self.name = name
        self.breed = breed
        self.age = age

    # pass

# my_dog = Dog()

# 上面的self.name = name 执行效果和下面的 三个语句相同
# my_dog.name = 'Champ the Wonder Dog'
# my_dog.breed = 'Great Dane'
# my_dog.age = 5

# print('Breed and age are {} and {}.'.format(my_dog.breed,my_dog.age))

top_dog = Dog('Handsome Dan', 'Bulldog', 10)


# print(top_dog.name)


class Pretty:
    def __init__(self, prefix):
        self.prefix = prefix

    def print_me(self, a, b, c):
        print(self.prefix, a, sep='')
        print(self.prefix, b, sep='')
        print(self.prefix, c, sep='')

printer = Pretty('--->')
printer.print_me(10,20,30)


'''封装'''
class Odd:
    def __init__(self):
        self.x = 10
        self.y = 20
        self.__z = 30

    def pr(self):
        print('__z=',self.__z)

o = Odd()
# print(o.__z)  对于__z 同一个类里可以访问，但在这里访问是一个错误，双下划线开头的变量和方法（除魔术方法）不可访问


'''继承，也称“子类化” '''
class Mammal:
    def __init__(self,name,size):
        self.name = name
        self.size = size

    def speak(self):
        print('My name is',self.name)

    def call_out(self):
        self.speak()
        self.speak()
        self.speak()


class Dog(Mammal):
    def speak(self):   # 重写了 speak 方法，实现了自己的 speak 方法
        print('ARF!')

class Cat(Mammal):
    def speak(self):   # # 重写了 speak 方法，实现了自己的 speak 方法
        print('Purrrrrrr!!!')

# 在子类中进行额外的初始化操作，可为子类编写新的 __init__ 方法
class Dogs(Mammal):
    def speak(self):
        print('ARF!')

    def __init__(self,name,size,breed):
        super().__init__(name,size)
        self.breed = breed


my_cat = Cat('Precious',17.5)
my_cat.call_out()

my_dog = Dogs('Handsome Dan', 'Bulldog', 10)
print(my_dog.breed)


'''多重继承（应该也叫多态吧？）'''



